﻿using System;
namespace Producers.Rr.Xtee.Riik.Ee.Producer.Rr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="RR410Request", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RR410Request))]
    public class RR410RequestSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IRR410Request clazz;
        
        public RR410RequestSerializer(IRR410Request clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("SeisugaKPV");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.SeisugaKPV))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("EhakTyybid");
            if (clazz.EhakTyybid!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.EhakTyybid))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : EhakTyybid");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Koodid");
            if (clazz.Koodid!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Koodid))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Koodid");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="SeisugaKPV") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR410Request>SeisugaKPV");
                }
                clazz.SeisugaKPV = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("SeisugaKPV")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR410Request>SeisugaKPV", Reader.LocalName);
            }
            if (Reader.LocalName=="EhakTyybid") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR410Request>EhakTyybid");
                }
                clazz.EhakTyybid = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("EhakTyybid")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR410Request>EhakTyybid", Reader.LocalName);
            }
            if (Reader.LocalName=="Koodid") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR410Request>Koodid");
                }
                clazz.Koodid = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Koodid")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR410Request>Koodid", Reader.LocalName);
            }
        }
    }
}
